package threadcoreknowledge.threadobjectclasscommonmethods.join;

import java.util.concurrent.TimeUnit;

public class Task extends Thread {
    private Thread[] threads;

    public void setThread(Thread[] threads) {
        this.threads = threads;
    }

    @Override
    public void run() {
        try {
            if (threads != null) {
                for (Thread t : threads
                ) {
                    System.out.println(t.getName() + "线程状态是:" + t.getState());
                }
            }

            for (int i = 0; i < 50; i++) {
                TimeUnit.MILLISECONDS.sleep(10);
                System.out.println(Thread.currentThread().getName() + " i is " + i);
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
